<?php
namespace App\Models;
/**
 * App\Models\AdminRoutesModel
 *
 * @property int $id 主键ID
 * @property string $path 路由
 * @property string|null $component component
 * @property string $name 名称
 * @property int $pid 上级组别
 * @property string|null $remark 描述
 * @property string|null $extra 扩展
 * @property string|null $icon 图标
 * @property int|null $is_valid 是否禁用
 * @property int $orderby 排序
 * @property \Illuminate\Support\Carbon|null $created_at
 * @property \Illuminate\Support\Carbon|null $updated_at
 * @property string|null $menu_id 关联权限ID
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel paginateFilter($perPage = null, $columns = [], $pageName = 'page', $page = null)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel query()
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel simplePaginateFilter($perPage = null, $columns = [], $pageName = 'page', $page = null)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereBeginsWith($column, $value, $boolean = 'and')
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereComponent($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereEndsWith($column, $value, $boolean = 'and')
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereExtra($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereIcon($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereIsValid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereLike($column, $value, $boolean = 'and')
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereMenuId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereOrderby($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel wherePath($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel wherePid($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereRemark($value)
 * @method static \Illuminate\Database\Eloquent\Builder|AdminRoutesModel whereUpdatedAt($value)
 * @mixin \Eloquent
 */
class AdminRoutesModel extends BaseModel
{
    protected $table = 'admin_routes';

    public function filter($data)
    {
        //
        $where = [];
        if (isset($data['id']))
        {
            $where[] = ['id', '=', $data['id']];
        }
        if (isset($data['routes_id']))
        {
            $this->getQueryByModel()->whereIn("id", $data['routes_id']);
        }
        if (isset($data['is_valid']))
        {
            $where[] = ['is_valid', '=', $data['is_valid']];
        }
        $this->getQueryByModel()->where($where);

        return $this->getQueryByModel();
    }


}
